<template>
	<div>
		<h1>登陆页面</h1>
		<h2><router-link to="/register">没有账号?去注册</router-link></h2>
		<input type="text" maxlength="11" placeholder="请输入您的手机号" v-model="tel"/>
		<input type="password" placeholder="请输入密码" v-model="password"/>
		<input type="button" value="登陆" @click="login">
	</div>
</template>

<script>
	import $ from "jquery"
	export default{
		data() {
			return {
				tel:'',
				password:''
			};
		},
		methods:{
			login:function(){
				var _this=this;
				$.ajax({
					url: "http://localhost:80/user/login",
					type: "post",
					data: {
						tel:_this.tel,
						password:_this.password
					},
					success: function(data) {
						sessionStorage.setItem("Access-Token",data.message);
						// 后端登陆成功
						_this.$router.push("/map");
					},
					error: function(data) {
						alert(data.responseJSON.message)
					}
				});
				
			}
		}
	}
</script>

<style>
</style>
